#include <string>
#include <Winsock2.h>
#include "hiredis/hiredis.h"
#include "event2/event.h"

class Publisher {
public:
    Publisher(const char* channel, const char* message1, const char* message2, int intervalSeconds);
    ~Publisher();
    void runEventLoop();

private:
    std::string m_channel;
    std::string m_message1;
    std::string m_message2;
    int m_intervalSeconds;
    int m_currentMessageIndex;
    redisContext* m_context;
    struct event_base* m_base;
    struct event* m_publishEvent;

    void publishMessage();
    void connectToRedis();
    void releaseRedisContext();
    void initializeLibevent();
    void cleanupLibevent();
    static void publishCallback(evutil_socket_t fd, short events, void* arg);
    void createPublishEvent();
};